package unimelb.discussiontracker.twitter.data.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "Interval")
@NamedQueries(value = {
        @NamedQuery(name = "Interval.FindAll", query = "SELECT interval FROM IntervalEntity interval ORDER BY interval.start DESC"),
        @NamedQuery(name = "Interval.FindByStartEnd", query = "SELECT interval FROM IntervalEntity interval WHERE interval.start = :start AND interval.end = :end") })
public class IntervalEntity {
    @Id
    @GeneratedValue
    @Column(name = "Id")
    private long id;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "StartDate")
    private Date start;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "EndDate")
    private Date end;

    @OneToMany(mappedBy = "interval")
    private Set<TopicIntervalAssociation> associatedTopics;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Date getStart() {
        return start;
    }

    public void setStart(Date start) {
        this.start = start;
    }

    public Date getEnd() {
        return end;
    }

    public void setEnd(Date end) {
        this.end = end;
    }

    public Set<TopicIntervalAssociation> getAssociatedTopics() {
        return associatedTopics;
    }

    public void setAssociatedTopics(Set<TopicIntervalAssociation> associatedTopics) {
        this.associatedTopics = associatedTopics;
    }

}
